package com.example.actuator.controller;

import com.example.actuator.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author void
 * @date 2020/5/18 22:58
 * @desc
 */
@RestController
@RequestMapping("/test")
public class TestController {
    
    @GetMapping("/hello/{name}")
    public String name(@PathVariable String name){
        return name+"1";
    }

    /**
     * 此写法必须传参数name,可以name没有值,会解析为空字符串
     * 但是不传name参数spring报错400  UnsatisfiedServletRequestParameterException
     * @param name
     */
    @GetMapping(value = "/test3", params = "name")
    public void testName(String name){
        System.out.println(name);
    }

    @GetMapping("/user")
    public User user(){
        return new User("void", 2);
    }
}
